package me.zhengjie.minbearwcs.controller.rework;

import lombok.RequiredArgsConstructor;
import me.zhengjie.minbearwcs.entity.DTO.transfer.Tuple;
import me.zhengjie.minbearwcs.serivce.rework.ReworkService;
import org.springframework.web.bind.annotation.*;
import me.zhengjie.minbearwcs.entity.DTO.response.Resp;
import me.zhengjie.minbearwcs.entity.DTO.rework.wms.ReworkInboundMesCallAgv;
import me.zhengjie.minbearwcs.entity.DTO.rework.wms.order.WmsReworkInboundOrder;
import me.zhengjie.minbearwcs.entity.DTO.rework.wms.order.WmsReworkOrder;

import java.util.Map;

@RestController
@RequiredArgsConstructor
public class ReworkWmsController {

    private final ReworkService reworkService;

    // 返工单下发
    @PostMapping("/rework/dispatch")
    public Resp reworkOrderReceive(@RequestBody WmsReworkOrder wmsReworkOrder) {
        Tuple<String> stringTuple = reworkService.reworkOrderReceive(wmsReworkOrder);
        return Resp.build()
                .code(stringTuple.success)
                .reason(stringTuple.value);
    }



    // 返工单完成通知
    @PostMapping("/rework/complete")
    public Resp reworkOrderComplete(@RequestBody Map<String,String> infoReq) {
        String reworkOrderCode = infoReq.get("reworkOrderCode");
        Tuple<String> stringTuple = reworkService.reworkOrderComplete(reworkOrderCode);
        return Resp.build()
                .code(stringTuple.success)
                .reason(stringTuple.value);
    }

}
